package org.example;

import org.example.AppConfig;
import org.example.TimeTask;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.ThreadPoolExecutor;

public class App {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        ThreadPoolExecutor executor = context.getBean(ThreadPoolExecutor.class);

        // 提交一个 10 秒的耗时任务
        executor.execute(new TimeTask(10));

        executor.shutdown(); // 等待任务完成后关闭线程池
    }
}
